package service

import (
	"context"
	"devops-super/api"
	v1 "devops-super/api/configs/v1"
	"devops-super/internal/model/entity"
)

// IDeviceGroupConfig 设备分组配置服务接口
type IDeviceGroupConfig interface {
	// Add 新增设备分组配置
	Add(ctx context.Context, in *entity.AppDeviceGroupConfig) (err error)

	// Upt 更新设备分组配置
	Upt(ctx context.Context, in *entity.AppDeviceGroupConfig) (err error)

	// GetPageLst 分页获取设备分组配置列表
	GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.AppDeviceGroupConfig], err error)

	// Del 删除设备分组配置
	Del(ctx context.Context, id int) (err error)

	// GetOne 获取单条设备分组配置
	GetOne(ctx context.Context, id int) (out *entity.AppDeviceGroupConfig, err error)

	// GetOptions 获取设备分组配置选项
	GetOptions(ctx context.Context, in *v1.DeviceGroupConfigGetOptionsReq) (out *v1.DeviceGroupConfigGetOptionsRes, err error)

	GetDeviceGroupGroupConfigs(ctx context.Context, in *v1.GetDeviceGroupGroupConfigsReq) (out *v1.GetDeviceGroupGroupConfigsRes, err error)
	SetDeviceGroupGroupConfigs(ctx context.Context, in *v1.SetDeviceGroupGroupConfigsReq) (err error)

	GetConfigByKey(ctx context.Context, deviceGroupId int64, groupName string, configKey string) (configValue string, err error)
}

var (
	localDeviceGroupConfig IDeviceGroupConfig
)

// DeviceGroupConfig 获取设备分组配置服务实例
func DeviceGroupConfig() IDeviceGroupConfig {
	if localDeviceGroupConfig == nil {
		panic("implement not found for interface IDeviceGroupConfig, forgot register?")
	}
	return localDeviceGroupConfig
}

// RegisterDeviceGroupConfig 注册设备分组配置服务实例
func RegisterDeviceGroupConfig(i IDeviceGroupConfig) {
	localDeviceGroupConfig = i
}
